<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a="http://richfaces.org/a4j" template="/tasks/tasks-frame.xhtml">

	<ui:param name="pageTitle"
		value="#{messages['page.tasks.index.title']}" />

	<ui:define name="subheader">#{messages['page.tasks.index.subheader']}</ui:define>

	<ui:define name="main">
		<h:form>
			<rich:dataTable style="width: 100%;" value="#{taskBean.getAll()}"
				var="task" id="table" rowClasses="odd-row, even-row"
				styleClass="stable">

				<ui:param name="applicationx"
					value="#{taskBean.getApplication(task)}" />

				<rich:column>
					<f:facet name="header">
						<h:outputText value="#{messages['task.name']}" />
					</f:facet>
					<h:outputText value="#{task.name}" converter="taskNameConverter" />
				</rich:column>

				<rich:column>
					<f:facet name="header">
						<h:outputText value="#{messages['task.createTime']}" />
					</f:facet>
					<h:outputText value="#{task.createTime}" />
				</rich:column>

				<rich:column>
					<f:facet name="header">#{messages['application.name']}</f:facet>
					<h:outputText value="#{applicationx.name}" />
				</rich:column>

				<rich:column>
					<f:facet name="header">#{messages['application.customer.name']}</f:facet>
					<h:outputText
						value="#{applicationx.applicant.lastname} #{applicationx.applicant.firstname}" />
				</rich:column>

				<rich:column>
					<f:facet name="header">#{messages['application.customer.pesel']}</f:facet>
					<h:outputText value="#{applicationx.applicant.pesel}" />
				</rich:column>

				<rich:column>
					<f:facet name="header">
						<h:outputText value="#{messages['task.assignee']}" />
					</f:facet>

					<ui:fragment rendered="#{!(task.assignee eq null) }">
						<h:outputText value="#{task.assignee}" />
					</ui:fragment>

					<ui:fragment rendered="#{(task.assignee eq null) }">
						<h:commandLink value="#{messages['task.take']}"
							action="#{taskBean.take(task)}" />
					</ui:fragment>
				</rich:column>
			</rich:dataTable>
		</h:form>
	</ui:define>
</ui:composition>
